/*
 * Esta clase sirva como intermediario entre una clase render y Main, que es donde esta la pantalla en si.
 *
 * This is part of the game The Rooms
 * Copyright (C) 2010  Elvio Sarquis
 *
 * Get the GNU GPL v3 in http://www.gnu.org/licenses/
 */

package rooms;

/**
 *
 * @author dask
 */
public class Screen {

    private char[][] screen;
    private int[][] color;

    public Screen(int x, int y){
        screen = new char[x][y];
        color = new int[x][y];
        for(int j=0; j<y; j++)
        for(int i=0; i<x; i++){
            screen[i][j] = '.';
            color[i][j] = 15;
        }
    }

    public void cls(){
        for(int j=0; j<screen[1].length; j++)
        for(int i=0; i<screen.length; i++){
            screen[i][j] = ' ';
            color[i][j] = 15;
        }
    }

    public void print(int x, int y, String str, int color){

        for(int i = 0; i < str.length(); i++)
            print(x + i, y, str.charAt(i), color);
    }

    public void print(int x, int y, int number, int color){

        Integer Num = new Integer(number);
        print(x, y, Num.toString(), color);
    }

    public void print(int x, int y, char cha, int color){

        if (x<screen.length && x>=0)
        if (y<screen[1].length && y>=0){
            screen[x][y] = cha;
            this.color[x][y] = color;
        }
    }

    public void setTile(int x, int y, char character, int color){
        screen[x][y] = character;
        this.color[x][y] = color;
    }

    public void setColor(int x, int y, int color){
        this.color[x][y] = color;
    }

    public char getChar(int x, int y){
        return screen[x][y];
    }

    public int getColor(int x, int y){
        return color[x][y];
    }

    public int getX(){
        return screen.length;
    }

    public int getY(){
        return screen[1].length;
    }
}
